<template>
	<view class="connections_wrap">
		<!-- <view class="flex nav_wrap">
			<view :class="nav_index == 0 ? 'nav_item active' : 'nav_item'" @click="toNav(0)">校友</view>
			<view :class="nav_index == 1 ? 'nav_item active' : 'nav_item'" @click="toNav(1)">好友</view>
			<view :class="nav_index == 2 ? 'nav_item active' : 'nav_item'" @click="toNav(2)">好友申请</view>
		</view> -->
		<scroll-view scroll-y="true" style="height: 100vh;" v-if="nav_index == 0">
			<view class="list_wrap" v-if="school_friend.length > 0">
				<view class="items-center mt-10 list-item" v-for="(item,index) in school_friend"
					@click="toDetail(item.id)">
					<view class="head_item flex justify-between">
						<view class="left_item flex" style="width: 79%;">
							<image class="image_7" :src="ossUrl + item.avatar" />
							<view>
								<view class="font_2">{{ item.nickname }}</view>
								<view class="font mt-8"><text class="row_1"
										style="max-width: 300rpx;display: inline-block;">{{ item.company_position }}</text>
									<text style="margin-left: 30rpx;vertical-align: top;">{{ item.mobile }}</text>
								</view>
							</view>
						</view>
						<view class="font_3">{{ item.company_industries }}</view>
					</view>
					<view class="company" v-if="item.company">
						<view class="">{{ item.company.name }}</view>
						<view class="mt-6 city">{{ item.company.address }}</view>
					</view>
				</view>
			</view>
			<view v-else style="text-align: center;margin-top: 130rpx;">暂无人脉~</view>
		</scroll-view>
	</view>
</template>

<script>
	import {
		remoteUrl,
		ossUrl
	} from '@/utils/config.js'
	import {
		schoolUser,
		friendUser
	} from '@/api/connections.js'
	export default {
		data() {
			return {
				ossUrl: ossUrl,
				remoteUrl: remoteUrl,
				nav_index: 0,
				school_friend: [],
				friend_list: []
			};
		},
		onLoad() {

			// this.getFriendUser()
		},
		onShow() {
			this.getSchoolUser()
		},
		onShareAppMessage(res) { //发送给朋友
			return {
				title: '小程序分享',
				imageUrl: '',
			}
		},
		methods: {
			// 获取校友列表
			getSchoolUser() {
				schoolUser().then(res => {
					if (res.code == 1) {
						this.school_friend = res.data
					}
				})
			},
			// 获取好友列表
			getFriendUser() {
				friendUser().then(res => {
					if (res.code == 1) {
						this.friend_list = res.data
					}
				})
			},
			toNav(index) {
				this.nav_index = index
			},
			toDetail(id) {
				if (!uni.getStorageSync('userInfo')) {
					uni.reLaunch({
						url: '/pages/login/login'
					})
				}
				uni.navigateTo({
					url: '../pages-list/network_detail/network_detail?id=' + id
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
	.connections_wrap {
		width: 100vw;
		height: 100vh;
		background: #F5F5F5;

		.nav_wrap {
			width: 100vw;
			height: 96rpx;
			align-items: center;
			padding: 0 28rpx;
			background: #fff;

			.nav_item {
				font-size: 30rpx;
				color: #989595;
				margin-right: 80rpx;
			}

			.active {
				color: #1C41F1;
				font-weight: bold;
				position: relative;
			}

			.active::after {
				content: "";
				width: 60rpx;
				border-bottom: 6rpx solid #1C41F1;
				position: absolute;
				bottom: -10rpx;
				left: 50%;
				transform: translate(-50%);
			}
		}

		.list_wrap {
			.list-item {
				width: 690rpx;
				margin: 20rpx auto;
				padding: 20rpx;
				background-color: #ffffff;
				border-radius: 12rpx;

				.head_item {
					width: 100%;

					.image_7 {
						border-radius: 120rpx;
						width: 100rpx;
						height: 100rpx;
						margin-right: 18rpx;
					}
				}

				.font {
					font-size: 24rpx;
					color: #00000050;
				}

				.font_2 {
					font-size: 30rpx;
					color: #000000;
				}

				.font_3 {
					font-size: 24rpx;
					color: #1C41F1;
					position: absolute;
					right: 42rpx;
					width: 200rpx;
					overflow: hidden;
					white-space: nowrap;
					text-overflow: ellipsis;
					text-align: right;
				}

				.company {
					width: 654rpx;
					padding: 10rpx 20rpx;
					margin: 20rpx auto 0;
					border-radius: 12rpx;
					background: #F2F2F2;

					.city {
						font-size: 20rpx;
						color: #00000050;
					}
				}
			}
		}
	}
</style>